import { CHANGE_NOTE_LIST, CHANGE_USER_LIST } from "./constant";
// 网络请求
import { getSearchForNote, getSearchForUser } from "@/services";

const changeNoteListAction = (data) => ({
  type: CHANGE_NOTE_LIST,
  data,
});

const changeUserListAction = (data) => ({
  type: CHANGE_USER_LIST,
  data,
});

export const searchContentAction = (data) => {
  return (dispatch) => {
    getSearchForNote(data).then((res) => {
      dispatch(changeNoteListAction(res.data.noteList));
    });
    getSearchForUser(data).then((res) => {
      dispatch(changeUserListAction(res.data.userList));
    });
  };
};
